package com.holly.common.utils;

import android.content.Context;
import android.content.SharedPreferences;
/**
 * @author Joey Huang（QQ:273179370）
 * @created 2016/6/30
 */
public class PrefUtils {
    private static final String TAG=L.createTag(null)+"PrefUtils";
    private static final String FILE_NAME="holly.xml";

    public static void putString(Context context, String key, String text){
        SharedPreferences mPref = context.getSharedPreferences(FILE_NAME,Context.MODE_PRIVATE);
        mPref.edit().putString(key,text).apply();
        L.i(TAG,"putString  key:"+key+" value:"+text);
    }

    public static String getString(Context context,String key,String def){
        SharedPreferences mPref = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
        return mPref.getString(key,def);
    }

    public static String getString(Context context,String key){
        SharedPreferences mPref = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
        return mPref.getString(key,"");
    }

    public static long getLong(Context context,String key, long def) {
        SharedPreferences mPref = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
        return mPref.getLong(key,def);
    }

    public static void putLong(Context context,String key, long value) {
        SharedPreferences mPref = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
        mPref.edit().putLong(key,value).apply();
    }
}
